#include<bits/stdc++.h>
#define XH(i,a,b) for(int i=a;i<b;++i)
#define XXH(i,a,b) for(int i=a-1;i>=b;--i)
#define LL long long
using namespace std;
int tmpINT; string tmpSTRING; char tmpCHAR; double tmpDOUBLE; LL tmpLONGLONG;

struct node
{
    int a,b;
};

bool cmp(node x,node y){
    double d1 = x.a*1.0/x.b,d2 = y.a*1.0/y.b;
    return d1>d2;
}

void solve(){
    int n,m;scanf("%d%d", &n,&m);
    vector<node>v(n);
    XH(i,0,n)scanf("%d", &v[i].a);
    XH(i,0,n)scanf("%d", &v[i].b);
    sort(v.begin(),v.end(),cmp);
    int cnt = 0,ans = 0;
    XH(i,0,n){
        cnt+=v[i].a;
        ans+=v[i].b;
        if(cnt>=m){
            int tcnt = cnt - v[i].a;
            int tans = ans - v[i].b;
            int j = i + 1;
            while(j<n){
                tcnt += v[j].a;
                tans += v[j].b;
                if(tans<ans)ans = tans;
                tcnt -= v[j].a;
                tans -= v[j].b;
                ++j;
            }
            printf("%d\n", ans); 
            return;
        }
    }
    printf("-1\n");
}

int main(){
    int t;scanf("%d",&t);
    for(int i = 0; i < t; ++i){
        solve();
    }

    return 0;
}
